
<%@ Page Language="C#" %>
<html>
 <head>
    <script language="C#" runat="server">

       public class Authors {
         
          private string name;
          private string initials;
 
          public Authors(string name, string initials) {
             this.name = name;
             this.initials = initials;
          }
          public string Name { get { return name; } }
          public string Initials { get { return initials; } }
       }

       void Page_Load(Object Sender, EventArgs e) {
	   	  int viewCount;
		  if (ViewState["viewCount"] != null)
		  	viewCount = (int)ViewState["viewCount"] + 1;
		  else
		  	viewCount = 1;
			
		 labelViews.Text = "Times page has been viewed: " + viewCount.ToString();
		 
		 ViewState["viewCount"] = viewCount;
	   
          if (!IsPostBack) {
             ArrayList values = new ArrayList();
 
             values.Add(new Authors("Alex Homer", "AH"));
             values.Add(new Authors("Dave Sussman", "DS"));
             values.Add(new Authors("Rich Anderson", "RA"));
             values.Add(new Authors("Rob Howard", "RH"));
             values.Add(new Authors("Brian Francis", "BF"));
 
             MyRepeater.DataSource = values;
             MyRepeater.DataBind();
          }
       }
       void MyRepeater_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {        
          ClickInfo.Text = "You selected the  " + ((Button)e.CommandSource).Text + " button <br>";
       }    
    </script>
 </head>
 <body>
    <h3><font face="Verdana">Event Bubbling Example with ViewState</font></h3>
     <asp:Label id=labelViews font-name="Verdana" font-size="14pt" runat="server"/>
    <form runat=server>
       <asp:Repeater id=MyRepeater OnItemCommand="MyRepeater_ItemCommand" runat="server">
          <HeaderTemplate>
             <table border=0 cellspacing=5>
                <tr>
                   <td><b>Author</b></td>
                   <td><b>Initials</b></td>
                </tr>
          </HeaderTemplate>
          <ItemTemplate>
             <tr>
                <td> <%# DataBinder.Eval(Container.DataItem, "Name") %> </td>
                <td> <ASP:Button Text=<%# DataBinder.Eval(Container.DataItem, "Initials") %> runat="server" /></td>
             </tr>
          </ItemTemplate>
          <FooterTemplate>
             </table>
          </FooterTemplate>
       </asp:Repeater>
       <p>
       <asp:Label id=ClickInfo font-name="Verdana" font-size="12pt" runat="server"/>
    </form>
 </body>
 </html>